package com.cool.modules.finance.constant;

import lombok.Getter;

@Getter
public enum InOrOutType {

    IN(1, "转入"),
    OUT(2, "转出");

    private final Integer type;

    private final String desc;

    InOrOutType(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static String getByType(Integer type) {
        InOrOutType enumByType = getEnumByType(type);
        if (enumByType != null){
            return enumByType.getDesc();
        }
        return null;
    }

    public static InOrOutType getEnumByType(Integer type) {
        for (InOrOutType inOrOutType : InOrOutType.values()) {
            if (inOrOutType.getType().equals(type)) {
                return inOrOutType;
            }
        }
        return null;
    }

}
